package com.samsung.app;

import android.os.Handler;
import org.cybergarage.upnp.ControlPoint;
import org.cybergarage.upnp.Device;
import org.cybergarage.upnp.device.DeviceChangeListener;
import org.cybergarage.upnp.device.NotifyListener;
import org.cybergarage.upnp.device.SearchResponseListener;
import org.cybergarage.upnp.ssdp.SSDPPacket;

public class MyControlPoint extends ControlPoint
  implements DeviceChangeListener, NotifyListener, SearchResponseListener
{
  private static final String DBG_TAG = "MYCP";
  public static final int DEVICEADDED = 256;
  public static final int DEVICEDELETED = 257;
  public static final String TAG = "myLog";
  public static final String TAG_INRY = "INRY";
  private static LiveShutter m_main;
  private static MyControlPoint mycp = null;
  private boolean bCheckOnce = false;
  Handler m_Handler;
  public boolean mdevicedAdded = false;
  String strUSN;

  private MyControlPoint()
  {
    Logger.d("INRY", "START CONTROL POINT!!");
    Logger.e("myLog", "----------- MyControlPoint!!!! -------------");
    addDeviceChangeListener(this);
    addNotifyListener(this);
    addSearchResponseListener(this);
    MSearchStart();
  }

  private void MSearchStart()
  {
    new Thread(new Runnable()
    {
      public void run()
      {
        boolean bool = false;
        while (true)
        {
          if (MyControlPoint.this.mdevicedAdded)
            return;
          if (!bool)
          {
            try
            {
              String str = Utils.getUserAgent();
              bool = MyControlPoint.this.start("ssdp:all", str);
              Logger.d("INRY", "ControlPoint start=" + bool);
              Thread.sleep(3000L);
            }
            catch (InterruptedException localInterruptedException)
            {
              localInterruptedException.printStackTrace();
            }
            continue;
          }
          MyControlPoint.this.search("ssdp:all");
          Logger.d("INRY", "ControlPoint search.");
          try{
          Thread.sleep(1000L);
          }
          catch(InterruptedException e){}
        }
      }
    }).start();
  }

  /** @deprecated */
  public static MyControlPoint getInstance()
  {
      if (mycp == null)
      {
        Logger.e("myLog", "----------- getInstance!!!! -------------");
        mycp = new MyControlPoint();
      }
      MyControlPoint localMyControlPoint = mycp;
      return localMyControlPoint;

  }

  private void setupPeerCamDevice(SSDPPacket paramSSDPPacket, int paramInt)
  {
    String str1;
    String str2;
    String str3;
    if (paramInt == 1)
    {
      Logger.d("INRY", "deviceNotifyReceived start");
      str1 = paramSSDPPacket.getNTS();
      str2 = paramSSDPPacket.getNT();
      str3 = paramSSDPPacket.getUSN();
      if (str2.equals("urn:schemas-upnp-org:service:ConnectionManager:1"))
      {
        if (paramInt != 1)
          break label147;
        Logger.d("INRY", "deviceNotifyReceived : " + str1 + ", strNT+ " + this.strUSN + ", strlocalUSN=" + str3);
        label87: if ((!"ssdp:alive".equals(str1)) || (this.bCheckOnce))
          break label193;
        this.strUSN = str3;
        this.bCheckOnce = m_main.GetInfomation_DSC();
      }
    }
    while (true)
    {
      return;
      Logger.d("INRY", "deviceSearchResponseReceived start");
      str1 = paramSSDPPacket.getNTS();
      str2 = paramSSDPPacket.getST();
      str3 = paramSSDPPacket.getUSN();
      break;
      label147: Logger.d("INRY", "deviceSearchResponseReceived : " + str1 + ", strNT+ " + this.strUSN + ", strlocalUSN=" + str3);
      break label87;
      label193: if (("ssdp:byebye".equals(str1)) && (this.bCheckOnce) && (this.strUSN.equals(str3)))
      {
        Logger.d("INRY", "!!!!!!! ssdp:byebye !!");
        m_main.byebye();
        continue;
      }
      if (!str3.equals(this.strUSN))
        continue;
      Logger.d("INRY", "1 CameraChange(subType) =" + str1);
      m_main.CameraChange(str1);
    }
  }

  public void SetHandler(Handler paramHandler)
  {
    this.m_Handler = paramHandler;
  }

  public void SetMain(LiveShutter paramLiveShutter)
  {
    m_main = paramLiveShutter;
  }

  public void deviceAdded(Device paramDevice)
  {
    m_main.DeviceChange(256, paramDevice);
    if (LiveShutter.DSCdevice != null)
      this.mdevicedAdded = true;
  }

  public void deviceNotifyReceived(SSDPPacket paramSSDPPacket)
  {
    setupPeerCamDevice(paramSSDPPacket, 1);
  }

  public void deviceRemoved(Device paramDevice)
  {
    m_main.DeviceChange(257, paramDevice);
  }

  public void deviceSearchResponseReceived(SSDPPacket paramSSDPPacket)
  {
    setupPeerCamDevice(paramSSDPPacket, 2);
  }
}

/* Location:           C:\Users\Chris\Desktop\viewfinder\com.samsung.app-34_dex2jar.jar
 * Qualified Name:     com.samsung.app.MyControlPoint
 * JD-Core Version:    0.6.0
 */